package fr.phil.filter;



import javax.servlet.ServletException;

import org.apache.log4j.Logger;
import org.hibernate.FlushMode;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.OpenSessionInViewFilter;

/**
 * @author Altenide-mov
 * surFiltre hibernate.
 * passe le mode flush sur auto.
 *
 */
public class MyFilterHib extends OpenSessionInViewFilter {

	/**
	 * The logger.
	 */
	private static final  Logger LOG = Logger.getLogger(MyFilterHib.class);

	@Override
	protected final void initFilterBean() throws ServletException {

		LOG.info("<<<================= OUVERTURE "
				+ "SESSION HIBERNATE ==============>>>");

		// for template one session per request turn flush mode in auto
		
		setFlushMode(FlushMode.AUTO);

	}
	
	





	@Override
	protected final void closeSession(final Session session, 
			final SessionFactory sessionFactory) {
		LOG.info("<<<================= FERMETURE"
				+ " DE LA SESSION HIBERNATE ==============>>>");
		
	}


}